﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Database;
using Business;

namespace DT5_Anh09110006_Hung09110044_Vu09110157.QuanLy
{
    public partial class InHoaDonHocPhi : System.Web.UI.Page
    {
        Business.QuanLyHocVien qlhocvien = new Business.QuanLyHocVien();
        Business.QuanLyHocVien_LopHoc qlhocvien_lophoc = new Business.QuanLyHocVien_LopHoc();
        protected void Page_Load(object sender, EventArgs e)
        {
            Panel1.Visible = false;
            if (!IsPostBack)
            {
                ddlMaHocVien.DataSource = qlhocvien.LayDanhSachHocVien();
                ddlMaHocVien.DataValueField = "MaHV";
                DataBind();
            }
        }
        protected void ddlMaHocVien_SelectedIndexChanged(object sender, EventArgs e)
        {
            HocVien hv = qlhocvien.LayHocVienTheoMa(ddlMaHocVien.SelectedValue);
            if (hv != null)
            {
                Panel1.Visible = true;
                lblMaHV.Text = hv.MaHV;
                lblbHoTenHV.Text = hv.HoTenHV;
                lblDiaChiHV.Text = hv.DiaChi;
                lblDienThoai.Text = hv.DienThoai;
                lblHocPhi.Text = qlhocvien_lophoc.TinhHocPhiHocVienTheoMa(hv.MaHV).ToString();
            }
            else
            {
                Panel1.Visible = false;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirectMe", "alert('Không tìm thấy học viên này');", true);
            }
        }       
    }
}